package com.smileus.service;

import java.util.List;
import java.util.Map;

import com.smileus.common.CallInfo;
import com.smileus.entity.ServiceRouter;
import com.smileus.integration.cluster.divert.CloseInterval;

public interface ClusterService {

	public abstract Map<CloseInterval, String> getCloseMapBySysDomain(String sysDomain);

	public abstract List<ServiceRouter> getListBySysDomain(String sysDomain);

	//	public ServiceRouter getCurtServiceRouter(){
	//		return null;
	//	}
	public abstract ServiceRouter getServiceRouterByPubAddress(String pubAddress);

	public abstract ServiceRouter saveOrUpdateServiceRouter(ServiceRouter serviceRouter);

	public abstract int getTotalWeight(String sysDomain);

	public abstract void clusterRefresh();

	/**
	 * 查询已启动的服务
	 * 
	 * @return
	 */
	// private static final String CURT_HQL =
	// " from ServiceRouter sr where sr.pubAddress = '" +
	// cfgRouter.getPubAddress() + "'";
	public abstract ServiceRouter getCurtServiceRouter();

	/**
	 * 刷新运行时服务列表，key是comDomain + "." + sysDomain形式，如:com.alipay.katong
	 * 
	 * @return
	 */
	public abstract Map<String, List<ServiceRouter>> refreshRunningMap();

	public abstract String selectUrl(String sysDomain, String suspendUrl);

	public abstract boolean incrementAndCheck(String url);

	public abstract int getMaxValue(Map<CloseInterval, String> map);

	public abstract String getSysDomain(ServiceRouter router);

	/**
	 * @param serviceId
	 * @return
	 */
	public abstract String getSysDomain(String serviceId);

	/**
	 * 注意：该CallInfo还不完整，只有sysDomain和service
	 * 
	 * @param serviceId
	 * @return
	 */
	public abstract CallInfo getCallInfo(String serviceId);

	public abstract String getWsAddress(ServiceRouter router);

	public abstract boolean sendMessage(ServiceRouter sRouter);
	
}